
import request from "@/api/request.ts";

// 获取用户列表
export function getUserListApi(params: object){
    return request({
        url: 'user',
        method: 'get',
        params
    })
}

/**
 * 新增管理员
 * @param data
 */
export function addUserApi(data: object){
    return request({
        url: 'user',
        method: 'post',
        data: data
    })
}

// 根据ID获取管理员信息
export function getUserApi(id: number) {
    return request({
        url: `user/detail/${id}`,
        method: 'get',
    })
}

/**
 * 编辑管理员
 * @param data
 */
export function editUserApi(data: object){
    return request({
        url: 'user',
        method: 'put',
        data: data
    })
}

export function delUserApi(id: number) {
    return request({
        url: `user/${id}`,
        method: 'delete'
    })
}

export function getAllRoleListApi() {
    return request({
        url: 'role/all',
        method: 'get'
    });
}

export function updateInfoApi(data: object) {
    return request({
        url: 'user/updateInfo',
        method: 'put',
        data
    })
}

export function sendEmailApi(email: string) {
    return request({
        url: 'user/sendEmail',
        method: 'get',
        params: {
            email
        }
    })
}

export function verifyCodeApi(code: string) {
    return request({
        url: 'user/verifyCode',
        method: 'get',
        params: {
            code
        }
    })
}

export function updateEmailApi(email:string,code: string) {
    return request({
        url: 'user/updateEmail',
        method: 'put',
        params: {
            email,
            code
        }
    })
}

export function updatePwdApi(data: object) {
    return request({
        url: 'user/updatePwd',
        method: 'put',
        data: data
    })
}